<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="utf-8">
    <title>Bootstrap Tree View</title>
<!--    <link href="http://jonmiles.github.io/bootstrap-treeview/bower_components/bootstrap/dist/css/bootstrap.css"
          rel="stylesheet">-->
    <link href="./plugins/tree-view/bootstrap-treeview.min.css" rel="stylesheet">
    <!-- DataTables -->
    <link rel="stylesheet" href="./plugins/datatables/dataTables.bootstrap4.css">
    <link rel="stylesheet" href="./dist/css/bootstrap.css">
    <style>
        body {
            font-size: 16px;
        }
    </style>
</head>
<body>
<!-- Main Sidebar Container -->
<div class="row col-12 " style="background-color: white">
    <div class="col-sm-2" style="float: left;">
        <button id="delete" class="btn btn-primary btn-sm">添加用户</button>
        <div id="treeview6" class=""></div>
    </div>
    <div style="width: 83.0%;" id="data-content">
        <div class="card-body" id="content">

        </div>
    </div>
</div>
<input name="comId" type="text" class="form-control" id="comId" value="" style="display: none">
<input name="subcomId" type="text" class="form-control" id="subcomId" value="" style="display: none">
<input name="depId" type="text" class="form-control" id="depId" value="" style="display: none">
<input name="posId" type="text" class="form-control" id="posId" value="" style="display: none">
<script src="./plugins/tree-view/bootstrap-treeview.js"></script>
<!-- DataTables -->
<script src="./plugins/datatables/jquery.dataTables.js"></script>
<script src="./plugins/datatables/dataTables.bootstrap4.js"></script>
<script type="text/javascript">
    $(function () {
        functionList();
    });

    function functionList() {
        var url = encodeURI("./CompanyInstituteList.action");
        $.ajax({
            type: 'POST',
            url: url,
            data: {},
            dataType: "json",
            success: function (result) {
                if (result.success) {
                    //刷新表格
                    var data = result.data;
                    $('#treeview6').treeview({
                        color: "#428bca",
/*                        expandIcon: "glyphicon glyphicon-stop",
                        collapseIcon: "glyphicon glyphicon-unchecked",
                        nodeIcon: "glyphicon glyphicon-user",*/
                        showTags: true,
                        levels: 1,
                        showCheckbox:false,//是否显示多选
                        onNodeSelected: function (event, data) {
                            if (data.href != null && data.href != '') {
                                eval(data.href);
                            }

                        },
                        data: data
                    });
                    actionTo(0,1);

                } else {

                }
            },
            dataType: "json"
        });


    }

    function menuSearchBtn() {
        $('#treeview6').empty();
        functionList();
    }

    function actionTo(id,type) {
        $("#content").load("./web/company.html",function () {
            loadData(id,type);
        });
    }

    function addNode(name,href) {
        //静态添加节点
        parentNode = $('#left-tree').treeview('getSelected');
        var node = {
            text: name,
            href:href
        };
        $('#left-tree').treeview('addNode', [node, parentNode]);
    }
</script>
</body>
</html>
